home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 17 / AMIGAplus Sonderheft 17 (1999)(ICP)(DE)[!].iso / Rexx / Aligner.AmiCAD < prev    next >
Text File  |  1998-05-23  |  2KB  |  61 lines

  1. /* Alignement des éléments sélectionnés */
  2. /* $VER: Aligner.AmiCAD 1.0 (© R.Florac, 23 mai 1998) */
  3. /* Ne gère correctement que les éléments du même type */
  4.  
  5. options results     /* indispensable pour récupérer le résultat des macros */
  6.  
  7. signal on error     /* pour l'interception des erreurs */
  8. signal on syntax
  9.  
  10. 'ALIGNEMENT=SELECT("Alignement"+CHR(10)+"En haut"+CHR(10)+"En bas"+CHR(10)+"À gauche"+CHR(10)+"À droite")'
  11. alignement=result
  12. select
  13.     when alignement=1 then ligne_base=50000
  14.     when alignement=2 then ligne_base=0
  15.     when alignement=3 then colonne_base=50000
  16.     when alignement=4 then colonne_base=0
  17.     otherwise exit
  18. end
  19.  
  20. objets=0
  21. 'FIRSTSEL'; i=result
  22. do while i>0
  23.     objets=objets+1
  24.     'LINE('i')'; ligne=result
  25.     'COL('i')'; colonne=result
  26.     select
  27.     when alignement = 1 then do
  28.         if ligne<ligne_base then ligne_base=ligne
  29.     end
  30.     when alignement = 2 then do
  31.         if ligne>ligne_base then ligne_base=ligne
  32.     end
  33.     when alignement = 3 then do
  34.         if colonne<colonne_base then colonne_base=colonne
  35.     end
  36.     otherwise do
  37.         if colonne>colonne_base then colonne_base=colonne
  38.     end
  39.     end
  40.     'NEXTSEL('i')'; i=result
  41. end
  42.  
  43. if objets<2 then do
  44.     'MESSAGE("Sélectionnez au moins"+CHR(10)+"deux éléments avant"+CHR(10)+"d''appeler ce script")'
  45.     exit
  46. end
  47.  
  48. 'SAVEALL(-1):O=FIRSTSEL:WHILE(O,IF(ALIGNEMENT<3,MOVE(O,0,'ligne_base'-LINE(O)),MOVE(O,'colonne_base'-COL(O),0)):O=NEXTSEL(O))'
  49.  
  50. exit
  51.  
  52. /* Traitement des erreurs, interruption du programme */
  53. syntax:
  54. erreur=RC
  55. 'MESSAGE("Erreur de syntaxe"+CHR(10)+"en ligne 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  56. exit
  57.  
  58. error:
  59. 'MESSAGE("Erreur en ligne 'SIGL'")'
  60. exit
  61.